package com.syqc.adapter

import android.widget.TextView
import androidx.core.view.isVisible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.syqc.entity.TeamInfo
import com.syqc.monitor.R

/**
 *@Author Jasper
 *@Time   2020/11/3
 *@Desc   车队选择
 */
class ChooseTeamAdapter :
    BaseQuickAdapter<TeamInfo, BaseViewHolder>(R.layout.item_choose_car) {
    //当数量为0是否显示
    var isChoose = false

    init {
        addChildClickViewIds(R.id.tvItemChoose)
    }

    override fun convert(holder: BaseViewHolder, item: TeamInfo) {
        holder.let {
            it.setText(R.id.tvItemName, "${item.teamName} (${item.carNum})")
            it.setImageResource(R.id.ivItemPic, R.mipmap.ic_team_pic)
            val tvItemChoose = it.getView<TextView>(R.id.tvItemChoose)
            tvItemChoose.isVisible = true
            if (isChoose) {
                tvItemChoose.isSelected = true
            } else {
                tvItemChoose.isSelected = item.carNum > 0
            }
        }
    }

}